package com.gluck.cases.app.biz.impl.excel;

import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;

import java.io.IOException;

/**
 * @ClassName CreateWorkBookHandle
 * @Desc sheet 创建handle
 * @Author shiyongzhe
 * @Date 2022/5/24 - 6:06 下午
 **/
public class CreateSheetHandler extends AbstractExcelHandler<Workbook> {

    @Override
    public void doHandler(Workbook wb, Builder<Workbook> excelBuilder) throws IOException {
        wb.createSheet(excelBuilder.getSheetname());
//        CellStyle style = wb.createCellStyle();
        wb.getSheetAt(0);
//        setStyle(wb, style, sheet);
        nextHandler.doHandler(wb, excelBuilder);
    }

    /**
     * 功能描述: 设置样式
     * @Params [wb, style]
     * @Return void
     * @Author I`m Gluck
     * @Date 2022/5/24
     */
    private void setStyle(Workbook wb, CellStyle style, Sheet sheet) {
        // 单元格换行
        style.setWrapText(true);
        //设置水平对齐方式
        style.setAlignment(CellStyle.ALIGN_CENTER);
        //设置自适应列宽
//        sheet.setDefaultColumnWidth(0);
//        sheet.autoSizeColumn(1, true);
    }
}
